﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T.ServiceComponent.Kernel.Service;

namespace T.FAS.Runtime.Base.SGSPI
{
    /// <summary>
    /// SG返回值扩展
    /// </summary>
    [Serializable]
    public class SGRetData : TBaseResult
    {
        public static SGRetData Ok()
        {
            return new SGRetData(1);
        }
        public static SGRetData NG(string message, bool userError = false)
        {
            return new SGRetData(userError ? 2 : 0, message);
        }
        public int state { get; set; }

        public string errmsg { get; set; }

        private object data { get; set; }

        public SGRetData(int state)
        {
            this.state = state;
            ResultState = true;
            ErrorCode = "";
            ErrorMessage = "";
            ReturnValue = data;
        }
        public SGRetData(int state, string message)
        {
            this.state = state;
            ResultState = false;
            ErrorCode = Convert.ToString(state);
            ErrorMessage = message;
            ReturnValue = data;
        }
        public SGRetData(object obj)
        {
            this.state = 1;
            //data = obj;
            ResultState = true;
            ErrorCode = "";
            ErrorMessage = "";
            ReturnValue = obj;
        }
    }
}
